<html>
<head><meta charset="utf-8"><title>Fixed crate graphs and optional builtin crates · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html">Fixed crate graphs and optional builtin crates</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="229086673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229086673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229086673">(Mar 06 2021 at 10:28)</a>:</h4>
<p>Regarding <a href="https://github.com/rust-analyzer/rust-analyzer/issues/6714">#6714</a>:<br>
Would a possible solution be to have a section in Cargo.toml which lists the 'optional' crates which your crate depends on (primarily the <code>rustc_*</code> internal crates).</p>
<p>That is, additionally (or even only) run <a href="https://github.com/rust-analyzer/rust-analyzer/blob/d50a37d3aa473937919030b39587df3d93f9bd8c/crates/project_model/src/workspace.rs#L450-L482">adding rustc_private crates</a> to packages which have:</p>
<div class="codehilite" data-code-language="TOML"><pre><span></span><code><span class="k">[package.metadata.rust-analyzer]</span>
<span class="n">rustc_private</span> <span class="o">=</span> <span class="kc">true</span>
</code></pre></div>
<p>in their <code>Cargo.toml</code></p>



<a name="229093436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229093436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229093436">(Mar 06 2021 at 12:17)</a>:</h4>
<p>Initial implementation in <a href="https://github.com/DJMcNab/rust-analyzer/tree/rustc_private_metadata">https://github.com/DJMcNab/rust-analyzer/tree/rustc_private_metadata</a></p>



<a name="229108340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229108340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229108340">(Mar 06 2021 at 16:00)</a>:</h4>
<p>Now in <a href="https://github.com/rust-analyzer/rust-analyzer/pull/7891">https://github.com/rust-analyzer/rust-analyzer/pull/7891</a></p>



<a name="229108636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229108636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229108636">(Mar 06 2021 at 16:05)</a>:</h4>
<p>Hmm, this almost sounds like we need to revamp sysroot handling to be closer to what rustc does</p>



<a name="229108684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229108684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229108684">(Mar 06 2021 at 16:05)</a>:</h4>
<p>It seems like it isn't entirely correct to treat the CrateGraph as purely an input to the system generated by Cargo or another build system</p>



<a name="229108835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229108835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229108835">(Mar 06 2021 at 16:07)</a>:</h4>
<p>That is probably so. In this case I want a minimum changeset which can even partially improve working with the <code>rustc_private</code> feature. I'm trying to work out what the root of the <code>rustc-dev</code> package is - I suspect it would be rustc_driver, but I can't be certain because the code which manages this is somewhat convoluted</p>



<a name="229112189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229112189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229112189">(Mar 06 2021 at 16:56)</a>:</h4>
<blockquote>
<p>I'm trying to work out what the root of the rustc-dev package is - I suspect it would be rustc_driver</p>
</blockquote>
<p>What do you mean by the root?</p>



<a name="229112219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229112219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229112219">(Mar 06 2021 at 16:57)</a>:</h4>
<p>the workspace includes things outside compiler/, including tools: <a href="https://github.com/rust-lang/rust/issues/76653#issuecomment-691574806">https://github.com/rust-lang/rust/issues/76653#issuecomment-691574806</a></p>



<a name="229112719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229112719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229112719">(Mar 06 2021 at 17:04)</a>:</h4>
<p>I mean that <code>extern crate miri;</code> then removing <code>miri</code> from <code>Cargo.toml</code> makes priroda no longer compile. <br>
Therefore, the <code>miri</code> library crate is not included in <code>rustc-dev</code>, even though <code>rust-analyzer</code> thinks it is.<br>
Indeed, <code>rust-analyzer</code> thinks the <code>miri</code> dependency <code>priroda</code> is using is the one from <code>rustc_dev</code>, instead of the one in <code>Cargo.toml</code><br>
And neither <code>miri</code> can actually use the <code>rustc_dev</code> packages in rust-analyzer, since they aren't workspace members.</p>



<a name="229112799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229112799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229112799">(Mar 06 2021 at 17:05)</a>:</h4>
<p>miri is separate component:</p>
<div class="codehilite"><pre><span></span><code>$ rustup component list | grep miri
miri-x86_64-unknown-linux-gnu
</code></pre></div>



<a name="229112804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229112804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229112804">(Mar 06 2021 at 17:05)</a>:</h4>
<p>I don't know how that interacts with rust-analyzer</p>



<a name="229112998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229112998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229112998">(Mar 06 2021 at 17:08)</a>:</h4>
<p>The <code>miri</code> component doesn't ship <code>libmiri.rlib</code> either, only</p>
<div class="codehilite"><pre><span></span><code>file:bin/miri
file:bin/cargo-miri
file:share/doc/miri/LICENSE-APACHE
file:share/doc/miri/LICENSE-MIT
file:share/doc/miri/README.md
</code></pre></div>
<p>That is, it only ships binaries, so we use a direct dependency on <a href="https://github.com/rust-lang/miri">https://github.com/rust-lang/miri</a></p>



<a name="229113091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229113091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229113091">(Mar 06 2021 at 17:09)</a>:</h4>
<p>However rust-analyzer thinks that the miri library found in <code>rustcSource/src/tools/miri</code> is the version of miri we are using, even though we have a direct path dependency</p>



<a name="229177762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229177762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229177762">(Mar 07 2021 at 10:50)</a>:</h4>
<p>I'm tempted to make it be required to use <code>[package.metadata.rust-analyzer] rustc_private=true</code> for using the rustc_private crates. So long as it's documented well, I feel like that would be a better state of affairs<br>
Doing that would avoid analysing the <code>rustc_private</code> crates for every workspace if <code>rustcSource</code> is set</p>



<a name="229187661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229187661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229187661">(Mar 07 2021 at 13:29)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/pull/7891">https://github.com/rust-analyzer/rust-analyzer/pull/7891</a> is ready for review.</p>



<a name="229309013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229309013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229309013">(Mar 08 2021 at 14:41)</a>:</h4>
<blockquote>
<p>Hmm, this almost sounds like we need to revamp sysroot handling to be closer to what rustc does</p>
</blockquote>
<p>I'd much rather revamp rustc's sysroot handling to be closer what rust-analyzer does. implicit deps via search paths are not the most convenient model for an IDE )</p>



<a name="229309159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229309159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229309159">(Mar 08 2021 at 14:42)</a>:</h4>
<p>what does rust-analyzer do?</p>



<a name="229309460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229309460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229309460">(Mar 08 2021 at 14:44)</a>:</h4>
<p>hmm, I'm not sure how we could change rustc without a big breaking change</p>



<a name="229309560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229309560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229309560">(Mar 08 2021 at 14:44)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates/near/229309159">said</a>:</p>
<blockquote>
<p>what does rust-analyzer do?</p>
</blockquote>
<p>r-a assumes that all external crates used by some crate are known in advance (passed in as a <code>CrateGraph</code>)</p>



<a name="229309802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229309802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229309802">(Mar 08 2021 at 14:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="211727">Jonas Schievink  [he/him]</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates/near/229309560">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates/near/229309159">said</a>:</p>
<blockquote>
<p>what does rust-analyzer do?</p>
</blockquote>
<p>r-a assumes that all external crates used by some crate are known in advance (passed in as a <code>CrateGraph</code>)</p>
</blockquote>
<p>yeah I don't see how that could work without breaking changes</p>



<a name="229309877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229309877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229309877">(Mar 08 2021 at 14:46)</a>:</h4>
<p>this needn't be breaking</p>



<a name="229309971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229309971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229309971">(Mar 08 2021 at 14:47)</a>:</h4>
<p>We'll need that info for build std anyway, so it is coming long-term</p>



<a name="229310092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229310092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229310092">(Mar 08 2021 at 14:48)</a>:</h4>
<p><code>build-std</code> will use different artifacts than the sysroot though, especially since people want to add feature flags to std</p>



<a name="229310130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229310130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229310130">(Mar 08 2021 at 14:48)</a>:</h4>
<p>I don't see how those models work together - build-std is <em>optional</em></p>



<a name="229310456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229310456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229310456">(Mar 08 2021 at 14:50)</a>:</h4>
<p>build-std does not help with rustc-internal crates I think</p>



<a name="229310871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229310871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229310871">(Mar 08 2021 at 14:53)</a>:</h4>
<p>We are agnostic of what process is actually used to build the code, we don't use rlibs. We only need to know deps between the crates. If something implements build-std, something knows about dependencies between sysroot crates, and can expose that info to rust-analyzer. </p>
<p>I think it is <strong>super duper crucially</strong>  important that we have a compilation model where everything is known in advance, so I'd rather not support <code>rustc_private</code> properly than to have search-path functionality impleted, which would make maintainint the "in advance" property hard to maintain.</p>



<a name="229311425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229311425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229311425">(Mar 08 2021 at 14:57)</a>:</h4>
<blockquote>
<p>I think it is super duper crucially important that we have a compilation model where everything is known in advance, so I'd rather not support rustc_private properly than to have search-path functionality impleted, which would make maintainint the "in advance" property hard to maintain.</p>
</blockquote>
<p>I just don't see how this is compatible with how rustc_private works though :/ that info is fundamentally not available ahead of time</p>



<a name="229311452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229311452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229311452">(Mar 08 2021 at 14:57)</a>:</h4>
<p>you could parse the crate-level attributes for <code>feature(rustc_private)</code> maybe?</p>



<a name="229311716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229311716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229311716">(Mar 08 2021 at 14:59)</a>:</h4>
<p>It's indeed not compatible with how <code>rustc_private</code>. So there's a tradeoff between "sane compilation model" and "supporting rustc_private correnctly". I think we should pick sane compilation model here</p>



<a name="229312173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229312173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229312173">(Mar 08 2021 at 15:01)</a>:</h4>
<p>would it be possible to handle these as some kind of 'weak' / 'lazy' dependencies? i.e. the possible set and where they come from is known beforehand, but not whether the dependency edge actually exists</p>



<a name="229312474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229312474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229312474">(Mar 08 2021 at 15:03)</a>:</h4>
<p>Can you talk about why you think this property is so important? "Rustdoc will never be fully supported" is a really bitter pill to swallow</p>



<a name="229312855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229312855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229312855">(Mar 08 2021 at 15:05)</a>:</h4>
<p>Other tools will be broken too, like clippy and miri and potentially rustfmt. And any third party tool that uses the libraries.</p>



<a name="229313204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229313204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229313204">(Mar 08 2021 at 15:08)</a>:</h4>
<p>It doesn't follow that rustdoc will never be supported :D</p>
<ul>
<li>first, we can use heuristic to shoehorn rustc_private into existing model. We already have <code>ruscSources</code>, which seems to work for some folks</li>
<li>rustdoc can begin using the standard compilation model, where all deps are explictly declared in Cargo.toml</li>
</ul>



<a name="229313434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229313434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229313434">(Mar 08 2021 at 15:09)</a>:</h4>
<p>The standard compilation model doesn't allow using precompiled libraries</p>



<a name="229313560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229313560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229313560">(Mar 08 2021 at 15:10)</a>:</h4>
<p>I worked very hard on <a href="https://github.com/rust-lang/rust/pull/79540">https://github.com/rust-lang/rust/pull/79540</a> and I'm not interested in undoing it</p>



<a name="229313768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229313768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229313768">(Mar 08 2021 at 15:11)</a>:</h4>
<p>Is there a guide for setting up rustcSources?</p>



<a name="229316463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229316463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229316463">(Mar 08 2021 at 15:27)</a>:</h4>
<p>No, there are no docs for working with rustc private</p>



<a name="229316491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229316491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229316491">(Mar 08 2021 at 15:27)</a>:</h4>
<p>the following works for me:</p>
<div class="codehilite"><pre><span></span><code>18:26:42|~/projects/rust/src/librustdoc|master✓
λ pwd
/home/matklad/projects/rust/src/librustdoc

18:26:44|~/projects/rust/src/librustdoc|master✓
λ bat -p .vscode/settings.json
{
    &quot;rust-analyzer.rustcSource&quot;: &quot;/home/matklad/projects/rust/Cargo.toml&quot;
}

18:26:47|~/projects/rust/src/librustdoc|master✓
λ code .
</code></pre></div>



<a name="229316623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229316623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229316623">(Mar 08 2021 at 15:28)</a>:</h4>
<p>(though for some reason it doesn't resolve methods from std)</p>



<a name="229316715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229316715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229316715">(Mar 08 2021 at 15:29)</a>:</h4>
<p>works for me = I click on <code>extern crate rustc_hir;</code> and get to its definiton</p>



<a name="229316797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229316797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229316797">(Mar 08 2021 at 15:29)</a>:</h4>
<p>This was implemented in <a href="https://github.com/rust-analyzer/rust-analyzer/pull/6524">https://github.com/rust-analyzer/rust-analyzer/pull/6524</a>, that's the best source of documentatin at the momentz</p>



<a name="229317377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229317377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229317377">(Mar 08 2021 at 15:32)</a>:</h4>
<p>hmm, it doesn't seem to have done anything for me</p>



<a name="229317396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229317396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229317396">(Mar 08 2021 at 15:32)</a>:</h4>
<p>let me try running <code>x.py check</code> and see if it helps</p>



<a name="229317642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229317642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229317642">(Mar 08 2021 at 15:34)</a>:</h4>
<p>oh well oops apparently x.py check is broken with <code>download-rustc</code> lol, I think that should hopefully be fixed with <a href="https://github.com/rust-lang/rust/pull/82739">https://github.com/rust-lang/rust/pull/82739</a></p>



<a name="229317679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229317679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229317679">(Mar 08 2021 at 15:34)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> we could do a quick screen share session right now, if that's helpful</p>



<a name="229317716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229317716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229317716">(Mar 08 2021 at 15:34)</a>:</h4>
<p>sure! give me a second</p>



<a name="229317722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229317722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229317722">(Mar 08 2021 at 15:34)</a>:</h4>
<p>x.py check shouldn't be relevant I think</p>



<a name="229317762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229317762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229317762">(Mar 08 2021 at 15:34)</a>:</h4>
<p><a href="https://meet.jit.si/708263872019464">Click to join video call</a></p>



<a name="229319407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229319407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229319407">(Mar 08 2021 at 15:44)</a>:</h4>
<p>ok cool we got rustcSources working and I'm going to write up docs for it this afternoon (either for rust-analyzer or rustc-dev-guide)</p>



<a name="229319422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229319422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229319422">(Mar 08 2021 at 15:44)</a>:</h4>
<p>Ok, <span class="user-mention" data-user-id="232545">@Joshua Nelson</span> now knows how to set this up, so you can ask them ^^</p>



<a name="229319541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229319541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229319541">(Mar 08 2021 at 15:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133169">matklad</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates/near/229311716">said</a>:</p>
<blockquote>
<p>It's indeed not compatible with how <code>rustc_private</code>. So there's a tradeoff between "sane compilation model" and "supporting rustc_private correnctly". I think we should pick sane compilation model here</p>
</blockquote>
<p>so to my understanding this is mostly "rustc_private won't be supported automatically and you'll need to do some setup work" which seems fine</p>



<a name="229319599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229319599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229319599">(Mar 08 2021 at 15:45)</a>:</h4>
<p>as long as it's <em>possible</em> to get it to work</p>



<a name="229329364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229329364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229329364">(Mar 08 2021 at 16:27)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> Your final comment does kind of make sense, but the behaviour of running cargo check (for build scripts) was already in the code<br>
I just added an opt-out</p>



<a name="229329460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229329460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229329460">(Mar 08 2021 at 16:27)</a>:</h4>
<blockquote>
<p>Your final comment does kind of make sense, but the behaviour of running cargo check (for build scripts) was already in the code</p>
</blockquote>
<p>well sure, but you can always change it :P</p>



<a name="229329522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229329522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229329522">(Mar 08 2021 at 16:27)</a>:</h4>
<p>it seems silly to require everyone who uses this feature to add the opt out themselves</p>



<a name="229329839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229329839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229329839">(Mar 08 2021 at 16:28)</a>:</h4>
<p>Well for example, I wouldn't opt out<br>
Since it's possible that it does improve code analysis somewhere in the rustc source.</p>



<a name="229329941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229329941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229329941">(Mar 08 2021 at 16:29)</a>:</h4>
<p><span class="user-mention silent" data-user-id="200146">Daniel Mcnab</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates/near/229329839">said</a>:</p>
<blockquote>
<p>Well for example, I wouldn't opt out<br>
Since it's possible that it does improve code analysis somewhere in the rustc source.</p>
</blockquote>
<p>but this is never the case</p>



<a name="229329968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229329968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229329968">(Mar 08 2021 at 16:29)</a>:</h4>
<p><code>cargo check</code> will <em>never</em> work out of the box</p>



<a name="229330095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229330095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229330095">(Mar 08 2021 at 16:29)</a>:</h4>
<p>It certainly appears to do something. The point is that it only runs <code>cargo check</code> to run build scripts.</p>



<a name="229330205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229330205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229330205">(Mar 08 2021 at 16:30)</a>:</h4>
<blockquote>
<p>It certainly appears to do something. </p>
</blockquote>
<p>can you describe what you mean by "do something"?</p>



<a name="229330338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229330338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229330338">(Mar 08 2021 at 16:31)</a>:</h4>
<p>Sure. It shows up in the bottom bar as <code>metadata rustc_mir</code> and friends<br>
And it doesn't hurt, at least on my machine.<br>
It must have been added for a reason.</p>



<a name="229330549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229330549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229330549">(Mar 08 2021 at 16:32)</a>:</h4>
<blockquote>
<p>It must have been added for a reason.</p>
</blockquote>
<p><a href="/user_uploads/4715/_IYcSPzxKB5HjvsBxPAlrjKw/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/_IYcSPzxKB5HjvsBxPAlrjKw/image.png" title="image.png"><img src="/user_uploads/4715/_IYcSPzxKB5HjvsBxPAlrjKw/image.png"></a></div>



<a name="229330945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229330945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229330945">(Mar 08 2021 at 16:34)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> if that is so, then would moving to <code>rustcPrivate.src</code> still make sense?<br>
In this world we'd remove the other setting and the lines of code which get disabled by it</p>



<a name="229330985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229330985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229330985">(Mar 08 2021 at 16:34)</a>:</h4>
<p>I'm still learning how to Zulip, sorry</p>



<a name="229331064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229331064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229331064">(Mar 08 2021 at 16:35)</a>:</h4>
<p>if we don't need to touch settings, it's better not to touch them indeed</p>



<a name="229332445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229332445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229332445">(Mar 08 2021 at 16:43)</a>:</h4>
<p>Right, I'm updated then</p>



<a name="229333373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229333373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229333373">(Mar 08 2021 at 16:48)</a>:</h4>
<p>Would it make sense for <code>[package.metadata.rust-analyzer]rustc_private=true</code> to imply <code>rust-analyzer.rustcSource="discover"</code> if it is otherwise unset.</p>



<a name="229333487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229333487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229333487">(Mar 08 2021 at 16:49)</a>:</h4>
<p>I don't think so -- this is "nightly" stuff, so I'd rather user opt-into settings.json somewhere</p>



<a name="229333547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229333547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229333547">(Mar 08 2021 at 16:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133169">matklad</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates/near/229333487">said</a>:</p>
<blockquote>
<p>I don't think so -- this is "nightly" stuff, so I'd rather user opt-into settings.json somewhere</p>
</blockquote>
<p>isn't the <code>package.metadata</code> already an opt-in?</p>



<a name="229333825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229333825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229333825">(Mar 08 2021 at 16:51)</a>:</h4>
<p>Sorry for the bors spam, I know I had permission before, wasn't aware it had been removed<br>
(Not that it shouldn't have been removed, it being removed is definitely right)</p>



<a name="229334301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229334301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229334301">(Mar 08 2021 at 16:54)</a>:</h4>
<p>It's a good thing this is landing today (because of the release). I can go around the respositories I know of and add this metadata so it doesn't break for people.</p>



<a name="229334927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229334927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229334927">(Mar 08 2021 at 16:57)</a>:</h4>
<p>No worries about bors, we pruned the perms a while ago indeed. Would be happy to grant r+ back if I get tired of r+ PRs myself :)</p>



<a name="229335655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229335655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229335655">(Mar 08 2021 at 17:01)</a>:</h4>
<p>I don't need it - I don't expect to be actively participating too much. It's the good thing of Rust, can just jump into almost any project and being sure that your contributions are at least 'correct', for some definition thereof</p>



<a name="229387042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229387042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229387042">(Mar 08 2021 at 22:22)</a>:</h4>
<p><span class="user-mention silent" data-user-id="200146">Daniel Mcnab</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates/near/229333373">said</a>:</p>
<blockquote>
<p>Would it make sense for <code>[package.metadata.rust-analyzer]rustc_private=true</code> to imply <code>rust-analyzer.rustcSource="discover"</code> if it is otherwise unset.</p>
</blockquote>
<p>I'm interested in adding this, but I'm not sure how - I got as far as</p>
<div class="codehilite" data-code-language="Diff"><pre><span></span><code><span class="gh">diff --git a/crates/project_model/src/workspace.rs b/crates/project_model/src/workspace.rs</span>
<span class="gh">index 1b53fcc30..47b332a32 100644</span>
<span class="gd">--- a/crates/project_model/src/workspace.rs</span>
<span class="gi">+++ b/crates/project_model/src/workspace.rs</span>
<span class="gu">@@ -443,6 +443,7 @@ fn cargo_to_crate_graph(</span>
         // If the user provided a path to rustc sources, we add all the rustc_private crates
         // and create dependencies on them for the crates which opt-in to that
         if let Some(rustc_workspace) = rustc {
<span class="gi">+            rustc_workspace.build_data_config.cargo_features.rustc_source = Some(crate::RustcSource::Discover);</span>
             handle_rustc_crates(
                 rustc_workspace,
                 load,
</code></pre></div>
<p>and gave up when it said the fields are private:</p>
<div class="codehilite"><pre><span></span><code>error[E0616]: field `build_data_config` of struct `CargoWorkspace` is private
error[E0616]: field `cargo_features` of struct `BuildDataConfig` is private
</code></pre></div>
<p>Also I think this is wrong in the first place because it only runs if rustc_source was already found :/</p>



<a name="229432270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229432270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229432270">(Mar 09 2021 at 07:14)</a>:</h4>
<p>What you'd want is to add an else branch to the <code>if has_private {if let ... {} else {/*launch discovery*/ }} </code><br>
I'm not certain what I called the variable</p>



<a name="229435248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/229435248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#229435248">(Mar 09 2021 at 07:51)</a>:</h4>
<p>It also turns out that this code was very useful for clippy, since clippy doesn't actually use a workspace<br>
A happy accident of improvement</p>



<a name="230154123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/230154123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#230154123">(Mar 13 2021 at 10:37)</a>:</h4>
<p>So I guess there is some reason that <code>rust-analyzer.rustcSource="discover"</code> cant be the default <em>always</em>, irrespective of what the package settings say?</p>



<a name="230154369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/230154369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#230154369">(Mar 13 2021 at 10:42)</a>:</h4>
<p>We don't want to load rustc crates for everyone who isn't working on the compiler and related tooling. This is essentially a nightly opt-in</p>



<a name="230155713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/230155713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#230155713">(Mar 13 2021 at 11:10)</a>:</h4>
<p>Ah so this loads things eagerly, not just when needed? I understand, makes sense.</p>



<a name="230159470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/230159470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#230159470">(Mar 13 2021 at 12:25)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> Basically, it would run <code>cargo metadata</code> on the rustc crates, but not analyse them if <code>rustc_dev</code> is installed and no crates in the current workspace (and dependency tree) use the metadata<br>
Personally, I think that could be a reasonable tradeoff, since I suspect the number of people who should have rustc_dev installed on their normal nightly should be small</p>



<a name="230159476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fixed%20crate%20graphs%20and%20optional%20builtin%20crates/near/230159476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fixed.20crate.20graphs.20and.20optional.20builtin.20crates.html#230159476">(Mar 13 2021 at 12:25)</a>:</h4>
<p>That would also get all crates from <a href="http://crates.io">crates.io</a> which rustc depends on</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>